#!/usr/bin/env python 
#!+_+ coding:utf-8 +_+

import httplib
import hashlib

def md5(*args):
    md5Ctx = hashlib.md5()
    for arg in args:
        md5Ctx.update(str(arg))
    return md5Ctx.hexdigest()

httpClient = httplib.HTTPConnection('localhost', 8090, timeout=30)  

token = "sdfsadfie"
publickey="publickey"
openid="243432"
channel = "weibo"

contents = [str(openid),str(channel),str(publickey),str(token)]
contents = sorted(contents)
signature = md5(*contents)

params = dict(openid=openid,channel=channel,publickey=publickey,signature=signature)

req="/auth/client?publickey={publickey}&openid={openid}&channel={channel}&signature={signature}".format(**params)

httpClient.request('GET', req)  
  
response = httpClient.getresponse()  
print response.status  
print response.reason  
print response.read() 
